<template>
  <div class="EmergencyList">
    <div class="flex location-wrap">
      <span class="white">当前位置：</span>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/EDManagement' }">应急处置</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/DisasterReporting' }">灾情信息</el-breadcrumb-item>
        <el-breadcrumb-item>灾情报送任务单</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="box">
      <!-- 列表筛选 -->
      <filterTitle @query="query" @reset="reset" :form="form" :formData="formData" labelWidth="140px"
        @node-click="handleSelectTree" @change="selectChange">
        <!-- <el-form slot="filter" class="form" ref="form" :model="form" inline size="small" label-width="140px">
          <el-form-item :label="item.label + '：'" v-for="(item, index) in formData" :key="index" :rules="rules[item.id]"
            :prop="item.id">
            <LsdForm :compData="item" :form="form" @node-click="handleSelectTree(arguments, item)"
              @change="selectChange(arguments, item)" />
          </el-form-item>
        </el-form> -->
      </filterTitle>
      <!-- 列表表格 -->
      <LsdTable slot="gjxm" :paginationAtrrs="paginationAtrrs" :compRef="table.compRef" ref="gjxm"
        @pageChange="handleSizeChange" :columns="table.columns" :title="table.title" :actions="table.actions"
        :tableData="table.tableData" :tableAttr="table.tableAttr" :isShowPage="table.isShowPage"
        :isSelectFlag="table.isSelectFlag" :isSequenceFlag="table.isSequenceFlag" @onActionClick="onActionClick" />
    </div>
    <!-- 弹窗信息 -->
    <LsdDialog :dialogConfig="dialogConfig" @handleBtn="handleBtn" @close="close">
      <LsdDialogTitle slot="dialog" :titleConfig="titleConfig" :activeNames="activeNames">
        <!-- 信息来源 -->
        <DialogForm ref="formConfigData" slot="slot1" @changeEvent="handleChange" :formConfig="formConfig1" />
        <!-- 任务信息 -->
        <div slot="slot2">
          <DialogForm ref="formComponentData" :formConfig="formConfig2" />
          <LsdTable slot="rwxx" :paginationAtrrs="paginationAtrrs" :autoHeight="tableList.autoHeight"
            :compRef="tableList.compRef" ref="gjxm" :columns="tableList.columns" :tableData="tableList.tableData"
            :tableAttr="tableList.tableAttr" :isSequenceFlag="tableList.isSequenceFlag" />
        </div>
        <div slot="slot3">
          <!-- 任务下发 -->
          <DialogForm ref="formInfoData" :formConfig="formInfoData" />
        </div>
        <div slot="slot4">
          <!-- 审批 -->
          <DialogForm ref="formCheckData" :formConfig="formCheckData" />
        </div>
      </LsdDialogTitle>
    </LsdDialog>
  </div>
</template>

<script>
// addAave, zqkcFeedbackUpdById,
import { zqbsSubmissionList, getYjsj, getYjsjGetById, zqbsSubmissiongetById, postDeleteData, exportFileApi } from "@/api/EmergencyDisposal/zqbs.js";
// 公共组件接口
import { getDictByGroupEmergency, getOrgDepartmentList } from "@/api/common.js";
import common from "@/utils/common.js";
import { showTime } from "@/lib";
import { flowSubmit } from "@/utils/flow";
export default {
  name: "EmergencyList",
  components: {},
  data() {
    return {
      xinzengNum: 0,
      zrbmOption: [],
      // 筛选信息
      formData: [
        {
          elType: "input",
          id: "emergencyEvent",
          label: "应急事件",
          attrs: {
            value: "",
            size: "small",
            "collapse-tags": true,
            clearable: true
          }
        },
        {
          elType: "select",
          id: "eventCode",
          label: "事件类别",
          dic: "dic_sjlb",
          attrs: {
            value: "",
            size: "small",
            // clearable: true,
            filterable: true,
            "collapse-tags": true,
            clearable: true
          },
          options: []
        },
        {
          elType: "select",
          id: "eventLvName",
          label: "事件级别",
          dic: "dic_sjjb",
          attrs: {
            value: "",
            // clearable: true,
            size: "small",
            filterable: true,
            "collapse-tags": true,
            clearable: true
          },
          options: this.banzuData
        },
        // {
        //   elType: "select",
        //   id: "operatId",
        //   label: "影响范围",
        //   dic: "dic_yxfw",
        //   attrs: {
        //     value: "",
        //     size: "small",
        //     // clearable: true,
        //     filterable: true,
        //     "collapse-tags": true
        //   },
        //   options: this.dishiData
        // },
        // {
        //   elType: "dateTimePicker",
        //   id: "occurrenceTime",
        //   label: "发生时间",
        //   attrs: {
        //     value: "",
        //     size: "small",
        //     type: "datetime",
        //     "value-format": "yyyy-MM-dd HH:mm:ss"
        //   }
        // },
        {
          elType: "dateTimePicker",
          id: "occurrenceTime",
          label: "发生时间",
          attrs: {
            value: "",
            size: "small",
            type: "datetimerange",
            "value-format": "yyyy-MM-dd HH:mm:ss",
            clearable: true
          }
        },

        {
          elType: "input",
          id: "taskName",
          label: "任务名称",
          dic: "dic_xxly",
          attrs: {
            value: "",
            size: "small",
            // clearable: true,
            filterable: true,
            "collapse-tags": true,
            clearable: true
          }
          // options: this.dishiData
        },

        // {
        //   elType: "select",
        //   id: "operatId",
        //   label: "报送单位/部门",
        //   // dic: "dic_xxly",
        //   dic: "dic_zrbm",
        //   attrs: {
        //     value: "",
        //     size: "small",
        //     // clearable: true,
        //     filterable: true,
        //     "collapse-tags": true,
        //     clearable: true
        //   },
        //   options: this.dishiData
        // },
        {
          elType: "selectTree",
          id: "operatId",
          name: "operat",
          label: "报送单位/部门",
          attrs: {
            value: "",
            clearable: true,
            "collapse-tags": true
          },
          options: {
            attrs: {
              value: ""
            }
          },
          treeData: {
            attrs: {
              data: []
            },
            props: {
              children: "children",
              label: "orgName",
              value: "id"
            }
          }
        },
        // {
        //   elType: "dateTimePicker",
        //   id: "issueTime",
        //   label: "下发时间",
        //   attrs: {
        //     value: "",
        //     size: "small",
        //     type: "datetime",
        //     "value-format": "yyyy-MM-dd HH:mm:ss"
        //   }
        // }
        {
          elType: "dateTimePicker",
          id: "issueTime",
          label: "下发时间",
          attrs: {
            value: "",
            size: "small",
            type: "datetimerange",
            "value-format": "yyyy-MM-dd HH:mm:ss",
            clearable: true
          }
        }
        // {
        //   elType: "select",
        //   id: "reportState",
        //   label: "状态",
        //   attrs: {
        //     value: "",
        //     size: "small",
        //     // clearable: true,
        //     filterable: true,
        //     "collapse-tags": true
        //   }
        //   // options: this.dishiData
        // }
      ],
      // 表格信息
      table: {
        isSelectFlag: false,
        compRef: "gjxm",
        isSequenceFlag: true,
        isShowPage: true,
        resetFlag: true,
        loading: false,
        title: "灾情报送任务单列表",
        actions: [
          // {
          //   id: "dialogVisible",
          //   text: "新增",
          //   type: "primary",
          //   btnAttr: { size: "small" }
          // },
          // {
          //   id: "dialogVisible",
          //   text: "研判",
          //   type: "",
          //   btnAttr: { size: "small" }
          // }
          {
            id: "onExport",
            text: "导出",
            type: "",
            btnAttr: { size: "small" }
          }
        ],
        tableData: [],
        columns: [
          {
            prop: "emergencyEvent",
            label: "应急事件",
            align: "left",
            "min-width": "230px",
            render: (h, { row }) => {
              return (
                <div>
                  {
                    <span
                      style='color:#3561fd;cursor:pointer;text-decoration: underline;'
                      {...{
                        on: {
                          click: () => {
                            this.handleEmergencyEvents(row);
                          }
                        }
                      }}
                    >
                      {row.emergencyEvent}
                    </span>
                  }
                </div>
              );
            }
          },
          {
            prop: "eventName",
            label: "事件类别",
            align: "center"
          },
          {
            prop: "eventLvName",
            label: "事件级别",
            align: "center"
          },
          {
            prop: "effectRange",
            label: "影响范围",
            align: "center"
          },
          {
            prop: "occurrenceTime",
            label: "发生时间",
            align: "center",
            "min-width": "150px"
          },
          {
            prop: "taskName",
            label: "任务名称",
            align: "left",
            "min-width": "200px"
            // render: (h, { row }) => {
            //   return (
            //     <div>
            //       {
            //         <span
            //           style='color:#3561fd;cursor:pointer;text-decoration: underline;'
            //           {...{
            //             on: {
            //               click: () => {
            //                 this.handleTaskName(row)
            //               }
            //             }
            //           }}
            //         >
            //           {row.taskName}
            //         </span>
            //       }
            //     </div>
            //   )
            // }
          },
          // {
          //   prop: "reportTaskListVos",
          //   label: "任务内容及要求",
          //   align: "center",
          //   "min-width": "120px",
          //   render: (h, { row }) => {
          //     return (
          //       row.reportTaskListVos.map(item => {
          //         // console.log(item,"????item");
          //         return (
          //           <tr>
          //             <td>{item.taskContent}</td>
          //           </tr>
          //         )
          //       })
          //     )
          //   }
          // },
          // {
          //   prop: "issueTime",
          //   label: "下发时间",
          //   align: "center",
          //   "min-width": "120px",
          //   render: (h, { row }) => {
          //     return (
          //       row.reportTaskListVos.map(item => {
          //         // console.log(item,"????item");
          //         return (
          //           <tr>
          //             <td>{item.issueTime}</td>
          //           </tr>
          //         )
          //       })
          //     )
          //   }
          // },
          // {
          //   prop: "dutyDept",
          //   label: "报送单位/部门",
          //   align: "center",
          //   "min-width": "120px",
          //   render: (h, { row }) => {
          //     return (
          //       row.reportTaskListVos.map(item => {
          //         // console.log(item,"????item");
          //         return (
          //           <tr>
          //             <td>{item.dutyDept}</td>
          //           </tr>
          //         )
          //       })
          //     )
          //   }
          // },
          // {
          //   prop: "reportTaskListVos",
          //   label: "任务内容及要求",
          //   align: "center",
          //   "min-width": "200px",
          //   render: (h, { row }) => {
          //     return (
          //       row.reportTaskListVos.map((item, index) => {
          //         // console.log(item,"????item",index);
          //         if (row.reportTaskListVos.length > 1 && index < row.reportTaskListVos.length - 1) {
          //           return (
          //             <tr style='border-bottom: 1px solid #EBEEF5;display: flex;height:50px;align-items:center;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 2;line-clamp: 2;'>
          //               <td>{item.taskContent}</td>
          //             </tr>
          //           );
          //         } else {
          //           return (
          //             <tr style='display: flex;height:50px;align-items:center;overflow: hidden;text-overflow: ellipsis;-webkit-line-clamp: 2;display: -webkit-box;-webkit-box-orient: vertical;line-clamp: 2;'>
          //               <td>{item.taskContent}</td>
          //             </tr>
          //           );
          //         }

          //       })
          //     );
          //   }
          // },
          {
            prop: "reportTaskListVos",
            label: "任务内容及要求",
            align: "left",
            "min-width": "200px",
            "show-overflow-tooltip": false,
            render: (h, { row }) => {
              return (
                row.reportTaskListVos.map((item, index) => {
                  // console.log(item,"????item",index);
                  if (row.reportTaskListVos.length > 1 && index < row.reportTaskListVos.length - 1) {
                    return (
                      <el-tooltip effect='dark' placement='top'>
                        <div slot='content'>{item.taskContent}</div>
                        <div style='border-bottom: 1px solid #EBEEF5;display:-webkit-box;height:48px;line-height: 48px;align-items:center;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp: 2;'>{item.taskContent}</div>
                      </el-tooltip>
                    );
                  } else {
                    return (
                      <el-tooltip effect='dark' placement='top'>
                        <div slot='content'>{item.taskContent}</div>
                        <div style='display:-webkit-box;height:48px;line-height: 48px;align-items:center;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp: 2;'>{item.taskContent}</div>
                      </el-tooltip>
                    );
                  }

                })
              );
            }
          },
          {
            prop: "issueTime",
            label: "下发时间",
            align: "center",
            "min-width": "150px",
            "show-overflow-tooltip": false,
            render: (h, { row }) => {
              return (
                row.reportTaskListVos.map((item, index) => {
                  // console.log(item,"????item");
                  if (row.reportTaskListVos.length > 1 && index < row.reportTaskListVos.length - 1) {
                    return (
                      <tr style='border-bottom: 1px solid #EBEEF5;display: flex;height:50px;align-items:center;'>
                        <td>{item.issueTime}</td>
                      </tr>
                    );
                  } else {
                    return (
                      <tr style='display: flex;height:50px;align-items:center;'>
                        <td>{item.issueTime}</td>
                      </tr>
                    );
                  }
                  // return (
                  //   <tr>
                  //     <td>{item.issueTime}</td>
                  //   </tr>
                  // )
                })
              );
            }
          },
          {
            prop: "dutyDept",
            label: "报送单位/部门",
            align: "center",
            "min-width": "120px",
            "show-overflow-tooltip": false,
            render: (h, { row }) => {
              return (
                row.reportTaskListVos.map((item, index) => {
                  // console.log(item,"????item");
                  if (row.reportTaskListVos.length > 1 && index < row.reportTaskListVos.length - 1) {
                    return (
                      <el-tooltip effect='dark' placement='top'>
                        <div slot='content'>{item.dutyDept}</div>
                        <div style='border-bottom: 1px solid #EBEEF5;display:-webkit-box;height:48px;line-height: 48px;align-items:center;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp: 2;'>{item.dutyDept}</div>
                      </el-tooltip>
                    );
                  } else {
                    return (
                      <el-tooltip effect='dark' placement='top'>
                        <div slot='content'>{item.dutyDept}</div>
                        <div style='display:-webkit-box;height:48px;line-height: 48px;align-items:center;overflow: hidden;text-overflow: ellipsis;display: -webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp: 2;'>{item.dutyDept}</div>
                      </el-tooltip>
                    );
                  }
                  // return (
                  //   <tr>
                  //     <td>{item.dutyDept}</td>
                  //   </tr>
                  // )
                })
              );
            }
          },
          {
            prop: "reportState",
            label: "状态",
            align: "center",
            "min-width": "100px",
            formatter: (row, column, cellValue, index) => {
              if (cellValue === "0") {
                return "编辑中";
              } else if (cellValue === "1") {
                return "待审批";
              } else {
                return "已下发";
              }
            }
          },
          // {
          //   prop: "cz",
          //   label: "操作",
          //   align: "center",
          //   fixed: "right",
          //   "min-width": "100px",
          //   render: (h, { row }) => {
          //     return (
          //       <div>
          //         {
          //           <span
          //             style='color:#3561fd;cursor:pointer;text-decoration: underline;margin:0 10px'
          //             // style: {display: row}
          //             {...{
          //               on: {
          //                 click: () => {
          //                   this.writeReport(row);
          //                 }
          //               }
          //             }}
          //           >
          //             {row.reportState === "1" ? "审批" : ""}
          //           </span>
          //         }
          //       </div>
          //     );
          //   }
          // }
          {
            prop: "cz",
            label: "操作",
            align: "center",
            "min-width": "120px",
            render: (h, scope) => {
              let arr = [];
              const userId = JSON.parse(sessionStorage.getItem("account")).id;
              const spPower = this.common.isHasPower("spr");
              if (scope.row.reportState == 1 && scope.row.nextAssignee && scope.row.nextAssignee.includes(userId) && scope.row.creatorDeptId == JSON.parse(sessionStorage.getItem("org")).orgId || spPower) {
                arr = ["审批"];
              } else {
                arr = [];
              }
              return (
                <div>
                  {
                    arr.map(item => {
                      return (
                        <span style='color:#3561fd;cursor:pointer;margin:0 2px' {...{
                          on: {
                            click: () => {
                              this.writeReport(scope.row);
                            }
                          }
                        }}>
                          {item}
                        </span>
                      );
                    })
                  }
                </div >
              );
            }
          }
        ],
        tableAttr: {
          "max-height": "470px",
          height: "470px",
          stripe: false,
          border: true,
          fit: true,
          "show-header": true,
          "highlight-current-row": true,
          "cell-style": {
            "font-size": "16px"
          },
          "header-cell-style": {
            "text-align": "center",
            "background-color": "#B1C8F9",
            border: "1px solid #ccc",
            "font-size": "16px"
          }
        }
      },
      tableList: {
        isSelectFlag: true,
        compRef: "rwxx",
        isSequenceFlag: true,
        isShowPage: true,
        resetFlag: true,
        autoHeight: true,
        loading: false,
        title: "灾情报送任务单列表",
        actions: [
          // {
          //   id: "dialogVisible",
          //   text: "新增",
          //   type: "primary",
          //   btnAttr: { size: "small" }
          // },
          // {
          //   id: "dialogVisible",
          //   text: "研判",
          //   type: "",
          //   btnAttr: { size: "small" }
          // }
          // {
          //   // id: "dialogVisible",
          //   text: "导出",
          //   type: "",
          //   btnAttr: { size: "small" }
          // }
        ],
        tableData: [
          {
            taskContent: "",
            dutyDeptId: ""
          }
        ],
        columns: [
          {
            prop: "taskContent",
            label: "任务内容及要求",
            align: "center",
            "min-width": "200px",
            "show-overflow-tooltip": false,
            render: (h, { row }) => {
              return (
                <div class='peizhi'>
                  <LsdForm
                    compData={{
                      elType: "input",
                      id: "taskContent",
                      label: "任务内容及要求",
                      attrs: {
                        // disabled:
                        //   _this.operat === "review" ||
                        //   !["task999"].includes(_this.$route.query.task) ||
                        //   ["task2", "task3"].includes(
                        //     _this.$route.query.returnFlow
                        //   ),
                        disabled: true,
                        autosize: true,
                        value: "",
                        placeholder: "请输入",
                        min: 0,
                        type: "textarea"
                      }
                    }}
                    form={row}
                    {...{
                      on: {}
                    }}
                  ></LsdForm>
                </div>
              );
            }
          },
          {
            prop: "dutyDeptId",
            label: "责任部门",
            align: "center",
            "min-width": "60px",
            render: (h, { row }) => {
              return (
                <div class='peizhi'>
                  <LsdForm
                    compData={{
                      elType: "select",
                      id: "dutyDept",
                      // name: "dutyDept",
                      label: "责任部门",
                      // dic: "dic_zrbm",
                      attrs: {
                        value: "",
                        clearable: true,
                        filterable: true,
                        disabled: true,
                        multiple: false,
                        "collapse-tags": true
                      },
                      options: this.zrbmOption
                    }}
                    form={row}
                    {...{
                      on: {}
                    }}
                  ></LsdForm>
                </div>
              );
            }
          }
        ],
        tableAttr: {
          // "max-height": "470px",
          // height: "470px",
          stripe: false,
          border: true,
          fit: true,
          "show-header": true,
          "highlight-current-row": true,
          "cell-style": {
            "font-size": "16px"
          },
          "header-cell-style": {
            "text-align": "center",
            "background-color": "#B1C8F9",
            border: "1px solid #ccc",
            "font-size": "16px"
          }
        }
      },
      // paginationAtrrs: {
      //   total: 0,
      //   layout: "total, sizes, prev, pager, next, jumper",
      //   "current-page": 1,
      //   "page-size": 10,
      //   "page-sizes": [10, 20, 30, 40, 50, 100]
      // },
      paginationAtrrs: {
        total: 0,
        "background": true,
        layout: "prev, pager, next",
        "current-page": 1,
        "page-size": 10
      },
      activeNames: ["1", "2", "3", "4"],
      form: {},
      pageNum: 1,
      multipleSelection: [],
      // 弹窗信息
      dialogConfig: {
        title: "灾情报送任务单",
        isShow: false,
        btnList: [
          {
            name: "同意",
            id: "consentSubmit", // 事件名
            type: "primary",
            size: "small"
          },
          // {
          //   name: "保存",
          //   id: "BSave", // 事件名
          //   size: "small"
          // },
          {
            name: "驳回",
            id: "reject", // 事件名
            size: "small"
          },
          {
            name: "取消",
            id: "getBack", // 事件名
            size: "small"
          }
        ]
      },
      // 折叠面板信息
      titleConfig: [
        {
          title: "信息来源",
          name: "1",
          slot: "slot1"
        },
        {
          title: "任务信息",
          name: "2",
          slot: "slot2"
        },
        {
          title: "任务下发",
          name: "3",
          slot: "slot3"
        },
        {
          title: "审核信息",
          name: "4",
          slot: "slot4"
        }
      ],
      formConfig1: {
        // disabled: true,
        formData: [
          {
            type: "select",
            label: "应急事件",
            prop: "emergencyId",
            name: "emergencyEvent",
            class: "sjgy",
            isDisabled: true,
            lableWidth: "120px",
            option: []
          },
          {
            type: "select",
            label: "事件类别",
            prop: "eventCode",
            name: "eventName",
            class: "half",
            isDisabled: true,
            lableWidth: "120px"
          },
          {
            type: "select",
            label: "事件级别",
            prop: "eventLvCode",
            name: "eventLvName",
            class: "half",
            isDisabled: true,
            lableWidth: "120px"
          },
          {
            type: "input",
            label: "影响范围",
            prop: "effectRange",
            class: "half",
            isDisabled: true,
            lableWidth: "120px"
          },
          {
            type: "dataPicker",
            label: "发生时间",
            prop: "occurrenceTime",
            class: "half",
            dateType: "datetime",
            isDisabled: true,
            lableWidth: "120px"
          },
          {
            type: "textarea",
            label: "事件概要",
            prop: "incidentOutline",
            class: "sjgy",
            isDisabled: true,
            lableWidth: "120px"
          }
          // {
          //   type: "upload",
          //   label: "附件",
          //   prop: "ztqks",
          //   lableWidth: "100px"
          // }
        ]
        // rules: {
        //   ztqk: [
        //     { required: true, message: "请选择响应命令单", trigger: "blur" }
        //   ]
        // }
      },
      formInfoData: {
        // disabled: true,
        formData: [
          // {
          //   type: "select",
          //   label: "应急事件",
          //   prop: "emergencyEvent",
          //   class: "sjgy",
          //   lableWidth: "100px",
          //   option: []
          // },
          {
            type: "input",
            label: "下发人",
            prop: "creator",
            class: "iputsse",
            isDisabled: true,
            lableWidth: "120px"
          },
          {
            type: "input",
            label: "单位及部门",
            prop: "creatorDeptName",
            class: "iputsse",
            isDisabled: true,
            lableWidth: "100px"
          },
          {
            type: "input",
            label: "下发时间",
            prop: "createTime",
            class: "iputsse",
            isDisabled: true,
            lableWidth: "100px"
          }
        ]

      },
      formConfig2: {
        // disabled: true,
        formData: [
          {
            type: "input",
            label: "任务名称",
            prop: "taskName",
            class: "sjgy",
            isDisabled: true,
            lableWidth: "120px"
          }
        ]
        // rules: {
        //   taskName: [
        //     { required: true, message: "请输入任务名称", trigger: "blur" }
        //   ]
        // }
      },

      formCheckData: {
        // disabled: true,
        formData: [
          {
            type: "input",
            label: "审批意见",
            // prop: "emergencyEvent",
            prop: "approvaOpinion",
            class: "sjgy",
            lableWidth: "120px"
            // option: []
          },
          {
            type: "input",
            label: "审批人",
            prop: "approvalUser",
            class: "iputsse",
            isDisabled: true,
            lableWidth: "120px"
          },
          {
            type: "input",
            label: "单位及部门",
            prop: "approvalDept",
            class: "iputsse",
            isDisabled: true,
            lableWidth: "100px"
          },
          {
            type: "input",
            label: "审批时间",
            prop: "approvalTime",
            class: "iputsse",
            isDisabled: true,
            lableWidth: "100px"
          }

        ]
        // rules: {
        //   emergencyEvent: [
        //     { required: true, message: "请输入审批意见", trigger: "blur" }
        //   ]
        // }
      },
      rules: {
        name: [
          { required: true, message: "请输入信息名称", trigger: "blur" }
        ]
      },
      options: {
        dic_sjlb: [],
        dic_sjjb: [],
        dic_yxfw: [],
        dic_xxly: [],
        dic_zrbm: []
      },
      editId: "", // 编辑id
      FilledBy: {}
    };
  },
  created() {
    this.list();
    this.getInputVal();
  },
  mounted() {
    const FilledBy = {
      creator: JSON.parse(sessionStorage.getItem("account")).realName,
      creatorId: JSON.parse(sessionStorage.getItem("account")).id,
      deptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
      unitDeptName: JSON.parse(sessionStorage.getItem("org")).orgName,
      createTime: new Date().toLocaleString(),
      approvalUserId: JSON.parse(sessionStorage.getItem("account")).id,
      approvalUser: JSON.parse(sessionStorage.getItem("account")).realName,
      pprovalDeptId: JSON.parse(sessionStorage.getItem("org")).orgCode,
      // approvalDept: JSON.parse(sessionStorage.getItem("org")).orgName,
      approvalDept: sessionStorage.getItem("dwbmName"),
      // approvalTime: new Date().toLocaleString()
      approvalTime: showTime(new Date())
    };
    this.FilledBy = FilledBy;
  },
  methods: {
    // 工作流审批
    gzlAudit(type, variable) {
      const data = {
        bizKey: this.editId,
        flowKey: "emergency_report_001",
        taskId: "task2",
        callbackUrl: "/emergency/emergencyReport/handleFlow",
        idea: type === 3 ? "1" : "0",
        variable,
        ideaMsg: this.$refs.formCheckData.form.approvalOpinion ? this.$refs.formCheckData.form.approvalOpinion : type === 3 ? "同意" : "驳回"
      };
      const successCallBack = () => {
        this.$message({
          message: `${type === 3 ? "审核" : "驳回"}成功`,
          type: "success"
        });
        this.dialogConfig.isShow = false;
        this.$refs.formCheckData.form.approvaOpinion = "";
        this.list();
      };
      flowSubmit(data, successCallBack, "审核");
    },
    // 重置
    reset() {
      this.form = this.$options.data().form;
      this.pageNum = 1;
      this.$refs.gjxm.paginationAtrrsInner["current-page"] = 1;
      this.list();
    },
    // 查询
    async query() {
      var timeAndSecond1 = "";
      if (this.form.issueTime === undefined || this.form.issueTime === "") {
        this.form.issueTime = "";
      } else {
        timeAndSecond1 = this.form.issueTime[1].slice(0, 10) + " " + "23:59:59";
      }
      const parmas = {
        pageNum: this.pageNum,
        pageSize: 10,
        reportState: 1,
        // effectRange: this.form.effectRange,
        // infoSourceCode: this.form.infoSourceCode,
        // noticeId: this.form.noticeId,
        // reportState: this.form.reportState,
        dutyDeptId: this.form.operat, // 报送单位
        emergencyEvent: this.form.emergencyEvent, // 应急事件
        eventCode: this.form.eventCode, // 事件类别
        eventLvCode: this.form.eventLvName, // 事件级别
        taskName: this.form.taskName, // 任务名称
        occurrenceStartTime: this.form.occurrenceTime ? this.form.occurrenceTime[0] : "", // 发生开始时间
        occurrenceEndTime: this.form.occurrenceTime ? this.form.occurrenceTime[1] : "", // 发生结束时间
        createStateTime: this.form.issueTime ? this.form.issueTime[0] : "", // 下发开始时间
        // createEndTime: this.form.issueTime ? this.form.issueTime[1] : "" // 下发结束时间
        createEndTime: this.form.issueTime ? timeAndSecond1 : "" // 报送结束时间
      };
      const res = await zqbsSubmissionList(parmas);
      this.table.tableData = res.data;
      this.paginationAtrrs.total = res.total;
    },
    handleBtn(item) {
      this[item.id]();
    },
    resetForm() {
      this.tableConfig.formData = this.$options.data().tableConfig.formData;
      this.list();
    },
    // 获取下拉框数据
    getInputVal() {
      this.formData.forEach((item) => {
        if (item.dic) {
          getDictByGroupEmergency({ groupCode: item.dic }).then(res => {
            const option = res.map((item) => {
              return {
                label: item.dicName,
                value: Number(item.dicCode)
              };
            });
            item.options = option;
          });
        } else if (item.elType === "selectTree") {
          // GetOrgTree().then(res => {
          getOrgDepartmentList({ orgId: JSON.parse(sessionStorage.getItem("org")).orgId }).then(res => {
            this.$nextTick(() => {
              if (item.label === "报送单位/部门") {
                this.$set(this.formData[5].treeData.attrs, "data", res);
              }
            });
          });
        }
      });
      // this.formConfig.formData.forEach((item) => {
      //   if (item.dic) {
      //     getDictByGroupEmergency({ groupCode: item.dic }).then(res => {
      //       const option = res.map((item) => {
      //         return {
      //           label: item.dicName,
      //           value: Number(item.dicCode)
      //         }
      //       })
      //       item.option = option
      //     })
      //   }
      // })
      this.formConfig1.formData.forEach((item) => {
        if (item.dic) {
          getDictByGroupEmergency({ groupCode: item.dic }).then(res => {
            const option = res.map((item) => {
              return {
                label: item.dicName,
                value: Number(item.dicCode)
              };
            });
            item.option = option;
          });
        }
      });
      // this.tableList.columns.forEach((item) => {
      //   console.log(item)
      //   if (item.dic) {
      //   }
      // })
      getDictByGroupEmergency({ groupCode: "dic_zrbm" }).then(res => {
        console.log(res, ">>>>>>res");
        const option = res.map((item) => {
          return {
            label: item.dicName,
            value: Number(item.dicCode)
          };
        });
        this.zrbmOption = option;
        console.log(this.zrbmOption, ">>>>>>>>zrbmOption");
      });
    },
    // 列表
    async list() {
      const parmas = {
        pageNum: this.pageNum,
        pageSize: 10,
        reportState: 1
      };
      const res = await zqbsSubmissionList(parmas);
      this.table.tableData = res.data;
      this.paginationAtrrs.total = res.total;
    },
    onActionClick(item, index) {
      this[item.id](); // 调用按钮对应方法
    },
    // 新增
    dialogVisible() {
      this.xinzengNum = 0;
      this.dialogConfig.isShow = true;
      this.$nextTick(() => {
        this.$refs.formCheckData.form = this.FilledBy;
      });
      this.formConfig1.formData.map(item => {
        if (item.label === "应急事件") {
          getYjsj().then(res => {
            const option = res.map((item) => {
              return {
                label: item.emergencyEvent,
                value: item.id
              };
            });
            item.option = option;

          });
        }
      });
    },
    // 应急事件 下拉监听
    handleChange(val) {
      console.log(val);
      getYjsjGetById({ id: val }).then(res => {
        console.log(res);
        this.$refs.formConfigData.form = res;
        this.$refs.formInfoData.form = res;
      });
    },
    // 列表筛选 组织机构
    handleSelectTree(arg, item) {
      if (item.id === "operatId") {
        this.$set(this.form, "operat", arg[0].id);
        this.$set(this.form, "operatId", arg[0].orgName);
      }
    },
    // 审核
    writeReport(val) {
      // console.log(val);
      this.editId = val.id;
      this.dialogVisible();
      if (val.reportState === "1") {
        this.dialogConfig.isShow = true;
        zqbsSubmissiongetById({ id: val.id }).then(res => {
          // console.log(res)
          this.$refs.formConfigData.form = res;
          this.$refs.formComponentData.form = res;
          this.$refs.formInfoData.form = res;
          this.tableList.tableData = res.reportTaskListVos;
          // this.tableData = res.reportTaskListVos
          // formComponentData
        });
      }
      this.xinzengNum = 1;
    },
    // 导出操作
    onExport() {
      const parmas = {
        reportState: 1,
        // effectRange: this.form.effectRange,
        // infoSourceCode: this.form.infoSourceCode,
        // noticeId: this.form.noticeId,
        // reportState: this.form.reportState,
        emergencyEvent: this.form.emergencyEvent, // 应急事件
        eventCode: this.form.eventCode, // 事件类别
        eventLvCode: this.form.eventLvName, // 事件级别
        occurrenceTime: this.form.occurrenceTime, // 发生时间
        taskName: this.form.taskName, // 任务名称
        issueTime: this.form.issueTime // 下发时间
      };
      exportFileApi(parmas).then(res => {
        common.downloadByBlob(res, `灾情报送${new Date().getTime()}.xlsx`);
      });
    },
    // 删除
    writeReportDelete(val) {
      console.log(val.id);
      postDeleteData({ id: val.id }).then(res => {
        console.log(res);
        this.$message({
          message: "删除成功",
          type: "success"
        });
        // 刷新页面
        this.list();
        // if(res === 1){
        //   this.$message({
        //     message: "删除成功",
        //     type: "success"
        //   })
        // // 刷新页面
        // this.list()
        // }else{
        //   this.$message({
        //     showClose: true,
        //     message: "删除失败",
        //     type: "error"
        //   })
        // }
      });
    },
    // 多选单选
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    selectChange(e, i) {
      console.log(e);
      console.log(i);
    },
    // 分页
    handleCurrentChange(val) {
      this.pageNum = val;
      this.list();
    },
    // 应急事件
    handleEmergencyEvents(val) {
      console.log(val);
      this.$router.push({
        path: "/EmergencyDetail",
        query: { id: val.emergencyId }

      });
    },
    // 详情
    handleTaskName(val) {
      // console.log(val.id)
      this.editId = val.id;
      // this.dialogVisible()
      if (val.reportState === "0") {
        this.dialogConfig.isShow = true;
        zqbsSubmissiongetById({ id: val.id }).then(res => {
          // console.log(res)
          this.$refs.formConfigData.form = res;
          this.$refs.formComponentData.form = res;
          this.$refs.formInfoData.form = res;
          this.tableList.tableData = res.reportTaskListVos;
        });
      }
      this.dialogConfig.btnList = [];
    },
    // 保存
    // async BSave() {
    //   console.log("提交")
    //   console.log(this.xinzengNum)
    //   // console.log(this.$refs.formConfigData.form)
    //   // console.log(this.$refs.formComponentData.form.taskName)
    //   // console.log(this.tableList.tableData)
    //   // 新增 保存
    //   if (this.editId === "") {
    //     const parmas = {
    //       emergencyId: this.$refs.formConfigData.form.id,
    //       taskName: this.$refs.formComponentData.form.taskName,
    //       reportTaskSaveDto: this.tableList.tableData
    //     }
    //     console.log(parmas)
    //     const res = await addAave(parmas)
    //     if (res) {
    //       this.$message({
    //         message: "保存成功",
    //         type: "success"
    //       })
    //       this.dialogConfig.isShow = false
    //       this.list()
    //     }
    //   } else {
    //     // 编辑 保存
    //     const parmas = {
    //       id: this.editId,
    //       emergencyId: this.$refs.formConfigData.form.emergencyId,
    //       taskName: this.$refs.formComponentData.form.taskName,
    //       reportTaskUpdDtos: this.tableList.tableData
    //     }
    //     console.log(parmas)
    //     const res = await zqkcFeedbackUpdById(parmas)
    //     if (res) {
    //       this.$message({
    //         message: "修改成功",
    //         type: "success"
    //       })
    //       this.dialogConfig.isShow = false
    //       this.list()
    //     }
    //   }

    // },
    // 审核 - 同意
    consentSubmit() {
      // console.log(this.$refs.formConfigData.form)
      // console.log(this.$refs.formCheckData.form, "黄建人")
      // console.log(this.$refs.formInfoData.form, "黄建人11111111")
      const parmas = {
        id: this.editId,
        approveSign: "pass",
        emergencyId: this.$refs.formConfigData.form.emergencyId,
        emergencyEvent: this.$refs.formConfigData.form.emergencyEvent, // 应急事件
        eventName: this.$refs.formConfigData.form.eventName, // 事件类别
        eventCode: this.$refs.formConfigData.form.eventCode, // 事件类别id
        eventLvName: this.$refs.formConfigData.form.eventLvName, // 事件级别
        eventLvCode: this.$refs.formConfigData.form.eventLvCode, // 事件级别id
        effectRange: this.$refs.formConfigData.form.effectRange, // 影响范围
        occurrenceTime: this.$refs.formConfigData.form.occurrenceTime, // 发生时间
        incidentOutline: this.$refs.formConfigData.form.incidentOutline, // 事件概要
        taskName: this.$refs.formComponentData.form.taskName,
        reportTaskUpdDtos: this.tableList.tableData,
        approvaOpinion: this.$refs.formCheckData.form.approvaOpinion === undefined ? "同意" : this.$refs.formCheckData.form.approvaOpinion,
        approvaUser: this.$refs.formCheckData.form.approvalUser, // 审批人
        approveUserId: this.$refs.formCheckData.form.approvalUserId, // 审批人id
        approveDept: this.$refs.formCheckData.form.approvalDept, // 审批部门
        approveDeptId: this.FilledBy.deptId, // 审批部门id
        approveTime: this.$refs.formCheckData.form.approvalTime, // 审批时间
        creator: this.$refs.formInfoData.form.creator, // 创建人
        createId: this.$refs.formCheckData.form.creatorId, // 创建人id
        creatorDeptId: this.$refs.formCheckData.form.deptId, // 创建人部门id
        creatorDeptName: this.$refs.formCheckData.form.unitDeptName // 创建人部门名称
      };
      // const res = await postCheck(parmas);
      // if (res) {
      this.gzlAudit(3, parmas);
      // this.$message({
      //   message: "提交成功",
      //   type: "success"
      // });
      // this.dialogConfig.isShow = false;
      // this.$refs.formCheckData.form.approvaOpinion = "";
      // this.list();

      // }
    },
    // 驳回
    reject() {
      console.log(this.$refs.formCheckData.form.approvaOpinion);
      console.log(this.$refs.formCheckData.form);
      const parmas = {
        // === "" ? '同意' : this.$refs.formCheckData.form.approvaOpinion
        id: this.editId,
        approveSign: "reject",
        approvaUser: this.$refs.formCheckData.form.approvalUser, // 审批人
        approveUserId: this.$refs.formCheckData.form.approvalUserId, // 审批人id
        approveDept: this.$refs.formCheckData.form.approvalDept, // 审批部门
        // approveDeptId: this.$refs.formCheckData.form.approvalUser, //审批部门id
        approveDeptId: this.FilledBy.deptId, // 审批部门id
        approveTime: this.$refs.formCheckData.form.approvalTime, // 审批时间
        creator: this.$refs.formCheckData.form.creator, // 创建人
        // createId: this.$refs.formCheckData.form.creatorId, // 创建人id
        createId: this.$refs.formInfoData.form.creatorId, // 创建人id
        creatorDeptId: this.$refs.formCheckData.form.deptId, // 创建人部门id
        creatorDeptName: this.$refs.formCheckData.form.unitDeptName, // 创建人部门名称
        approvaOpinion: this.$refs.formCheckData.form.approvaOpinion === undefined ? "驳回" : this.$refs.formCheckData.form.approvaOpinion

      };
      // const res = await postCheck(parmas);
      // if (res) {
      this.gzlAudit(4, parmas);
      // this.$message({
      //   message: "驳回成功",
      //   type: "success"
      // });
      // this.dialogConfig.isShow = false;
      // this.$refs.formCheckData.form.approvaOpinion = "";
      // this.list();
      // }
    },
    // 取消
    getBack() {
      this.$refs.formCheckData.form.approvaOpinion = "";
      this.dialogConfig.isShow = false;
    },
    close() {
      this.$refs.formCheckData.form.approvaOpinion = "";
      this.dialogConfig.isShow = false;
    },
    // 分页
    handleSizeChange(val) {
      this.pageNum = val["current-page"];
      this.pageSize = val["page-size"];
      this.list();
    }
  }
};
</script>

<style scoped lang="less">
// @import '../../../assets/style/ComponentStyle.less';
@import "../../../assets/style/common.less";
@import "../../../assets/style/ComponentStyle.less";
@import "../../../assets/style/pop-upNotification.less";

:deep(.el-breadcrumb__inner.is-link) {
  font-weight: 100;
  color: #fff;
}

.EmergencyList :deep(.el-breadcrumb__item:last-child .el-breadcrumb__inner) {
  color: #3270ff;
}

/deep/ .el-table tr {
  background: none !important;
}

.box {
  // width: 100%;
  // height: 80vh;
  // padding: 0;
  // margin: 0;
  margin-top: 20px;
  background-color: #fff;
  border-radius: 4px;
  padding: 10px;
  box-sizing: border-box;
}
</style>
